package com.sg.plmadapter.adapters;

import com.mobnut.db.model.PrimaryObject;
import com.sg.business.model.Document;
import com.sg.business.model.IPLM_Object;
import com.sg.plmadapter.windchill.PMWebservice;

public class RemoveDocument extends WindchillSyncJob {

	private String deleteAction;
	private String type;
	private int deleteDocument;

	public RemoveDocument(PMWebservice windchill, PrimaryObject po,
			String deleteAction, String type) {
		super(windchill, po);
		this.deleteAction = deleteAction;
		this.type = type;
	}

	@Override
	protected void run(PMWebservice windchill, PrimaryObject po)
			throws Exception {
		setDeleteDocument(windchill.deleteDocument(type,
				po.get_id().toString(), deleteAction));
	}

	@Override
	protected String getRequestCode() {
		if (Document.REMOVE_TYPE_ALL.equals(deleteAction)) {
			return IPLM_Object.REQUEST_REMOVE_ALL;
		}
		if (Document.REMOVE_TYPE_SV.equals(deleteAction)) {
			return IPLM_Object.REQUEST_REMOVE_SV;
		}
		if (Document.REMOVE_TYPE_MV.equals(deleteAction)) {
			return IPLM_Object.REQUEST_REMOVE_MV;
		}
		return "";
	}

	public int getDeleteDocument() {
		return deleteDocument;
	}

	public void setDeleteDocument(int deleteDocument) {
		this.deleteDocument = deleteDocument;
	}

	@Override
	protected boolean canReload(PrimaryObject po) {
		return false;
	}

}
